#include "helpers.h"

std::list<std::string> SplitStringByDelimiter(std::string input_string, char delim)
{
	std::list<std::string> elements;
	std::stringstream ss(input_string);
	std::string item;

    while (std::getline(ss, item, delim))
	{
		elements.push_back(item);
	}
	return elements;
}

std::string LoadFileContentsIntoString(const char* filename)
{
	std::ifstream in(filename, std::ios::in | std::ios::binary);
	std::string contents;

	if (in)
	{
		in.seekg(0, std::ios::end);
		contents.resize(in.tellg());

		in.seekg(0, std::ios::beg);
		in.read(&contents[0], contents.size());

		in.close();
	}

	return(contents);
}

void RangeContraint(float& in, float min, float max)
{
	if (in < min)
		in = min;
	if( in > max)
		in = max;
}